/**
 * 修饰符
 * public: 不写就默认是public，可以在本类中、子类中、外部使用
 * private：私有的，只能在本类中使用
 * protected：受保护的，只能在本类中、子类中使用
 */
class Fruit {
    public name: string; 
    private address: string;
    protected color: string;

    constructor(name: string, address: string, color: string) {
        this.name = name;
        this.address = address;
        this.color = color;
    }

    setColor(color: string): void {
        this.color = color;
    }

    getColor(): string {
        return this.color
    }

    protected desc(): string {
        return `${this.name}生长在${this.address},它的颜色是${this.color}`
    }
}

var f = new Fruit('苹果', '烟台', '绿色');
console.log(f.getColor())
// console.log(f.age)
// console.log(f.color)
// console.log(f.desc())

// 子类继承
class Banana extends Fruit {
    constructor(name: string, address: string, color: string) {
        super(name, address, color)
    }

    report(): string {
        return `新闻报道: ${this.desc()}`
    }
}

var banana = new Banana('香蕉', '烟台', '黄色');
console.log(banana.report())